﻿# coding: utf-8

from Command import CCommand

class CCmdGroupCommand(CCommand):
    def __init__(self, **p):
        """
        Default class contructor.
        
        Parameters:
        @param cmdList - command list [cmd1, cmd2, ...]
        """
        
        CCommand.__init__(self, TD.CMD_GROUP_COMMAND, **p)
        
    def DoCmd(self):
        try:
            cmdList = self._paramDict['cmdList']
            
            # Do every command in cmdList
            for cmd in cmdList:
                cmd.DoCmd()
                
        except:
            SHOW_TRACE()
            
    def UndoCmd(self):
        try:
            cmdList = self._paramDict['cmdList']
            
            invalid = True
            
            # Undo every command in cmdList
            for cmd in cmdList:
                if not cmd.UndoCmd():
                    invalid = False
                
        except:
            SHOW_TRACE()
            
        return invalid